
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <meta charset="utf-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>后台管理</title>
    <link href="/jquery-ui/jquery-ui.min.css" rel="stylesheet" type="text/css">
    <link href="/base/stylesheets/common.css" rel="stylesheet" type="text/css">
    <link href="/dialog/jquery.dialog.css" rel="stylesheet" type="text/css">
    <link href="/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
    <link href="/base/stylesheets/admincp.css" rel="stylesheet" type="text/css">
    <link href="/fancybox/jquery.fancybox.css" rel="stylesheet" type="text/css">
</head>

<body>
    <div class="admincp-container">
    	<div class="admincp-menu">
    		<div class="menu-top">
    			<img src="/base/images/avatar.jpg" class="logo" />
    		</div>
    		<div class="menu-list">
				<!--菜单列表-->
				<input type="hidden" id="name" name="name" value="${(resultMap.user.name)?default('')}" />
				<input type="hidden" id="userName" name="userName" value="${(resultMap.user.username)?default('')}" />
				<input type="hidden" id="userId" name="userId" value="${(resultMap.user.id)?default('')}" />
				<#list resultMap.menuList as result>
				<div class="menu-box">
					<a href="javascript:void(0)" class="parent">
						<i class="icon-menu icon-default"></i>
						   ${result.rule.name}
						<span class="fa fa-angle-down"></span>
					</a>
					<ul class="menu-sub" style="display:none;">
						<#list result.subList as subMenu>
						<li><a data-href="${subMenu.url}" href="javascript:void(0)">${subMenu.name}</a></li>
						</#list>
					</ul>
					</div>
				</#list> 
				
            </div>
    	</div>
    	
    	<div class="admincp-main">
    		<div class="admincp-header">
    			<div class="left">
    				<a href="javascript:void(0)" title="展开/收缩菜单" id="navSwitch" class="btn btn-success"><i class="fa fa-bars"></i></a>
    			</div>
    			<div class="right">
    				<div id="welcome" class="admin-user-info"></div>
    				<div class="user-panel">
    					<a href="javascript:void(0)" class="iframe" ><i class="fa fa-key"></i> 修改密码</a>
    					<a href="http://www.szzjcx.com" target="_blank"><i class="fa fa-home"></i> 技术支持</a>
						<a href="auth/user/login.html"><i class="fa fa-sign-in"></i> 退出系统</a>
    				</div>
    			</div>
			</div>
   		
    		<iframe id="iframeMain" style="overflow:visible;" frameborder="0" width="100%" height="94%" scrolling="yes"></iframe>
    	</div>
    	
    </div>

    <script src="/base/javascripts/jquery-1.12.3.min.js"></script>
    <script src="/base/javascripts/jquery.cookie.min.js"></script>
    <script src="/jquery-ui/jquery-ui.min.js"></script>
    <script src="/dialog/jquery.dialog.js"></script>
    <script src="/base/javascripts/jquery.slimscroll.min.js"></script>  
    <script src="/base/javascripts/common.js"></script>
    <script src="/fancybox/jquery.fancybox.pack.js"></script>
    
    
    <script type="text/javascript">
    $(function() {
    	$('.iframe').on('click',function() {
    		var id= $("#userId").val();
			 $.sui.dialog.open("/auth/user/toUpdatePassword?id="+id,null,function(data){
			}); 
		});
		
        //菜单cookie
        var _parentCookie = "@_MENU_PARENT_ID";
        var _currentCookie = "@_MENU_CURRENT_ID";
        
		//顶部菜单
		$('.admincp-header .user-panel .iframe').click(function() {
			var url = $(this).data('href');
			$('#iframeMain').attr('src', url);
		});
		
		// Title提示美化
		$(document).tooltip({
			track: true
		});
		
		// 欢迎提示
		function greetings(){

			var day = new Date;
			var hr = day.getHours();
			if(hr > -1 && hr < 6) return '夜深了';
			if(hr > 5 && hr < 11) return '早上好';
			if(hr > 10 && hr < 15) return '中午好';
			if(hr > 14 && hr < 19) return '下午好';
			if(hr > 18 && hr < 24) return '晚上好';
		}
		var name = $("#name").val();
		$('#welcome').html('<i class="fa fa-bus"></i> '+name+' ' + greetings() + '，欢迎您~！');
		
		//展开和收起菜单
		var navFlag = true;
		$('#navSwitch').click(function() {
			if(navFlag) {
				navFlag = false;
				$('.admincp-menu').animate({width:0}, 'fast');
				$('.admincp-main').animate({left:0}, 'fast');
			} else {
				navFlag = true;
				$('.admincp-menu').animate({width:'219px'}, 'fast');
				$('.admincp-main').animate({left:'219px'}, 'fast');
			}
		});
		
		//菜单滚动条美化
		$('.admincp-menu').slimscroll({
			width: '219px',
			height: '100%'
		});

		//展开菜单
		$('.menu-box .parent').click(function() {
			
			$('.menu-box-highlight').removeClass('menu-box-highlight');
			$(this).parent().addClass('menu-box-highlight');
			
			$('.menu-box .parent .fa-angle-up').removeClass('fa-angle-up').addClass('fa-angle-down');
			if($(this).next('ul').is(':hidden')) {
				$(this).children('.fa').removeClass('fa-angle-down').addClass('fa-angle-up');
				$('.menu-sub').slideUp('fast');
				$(this).next('ul').slideDown('fast');
			} else {
				$(this).children('.fa').removeClass('fa-angle-up').addClass('fa-angle-down');
				$(this).next('ul').slideUp('fast');
			}
		});
		
		//点击链接
		$('.menu-sub a').click(function() {
			$('.menu-sub .current').removeClass('current');
			$(this).parent().addClass('current');
			$('#iframeMain').attr('src', $(this).data('href'));
            
            // 将当前点击的菜单项写入cookie
            var parentId = $('.menu-sub').index($(this).parent().parent());
            var currentId = $(this).parent().index();
            $.cookie(_parentCookie, parentId, {path:'/'});
            $.cookie(_currentCookie, currentId, {path:'/'});
            
		});

        // 展开默认菜单
		var initMenu = function(){
            // 从cookie中展开指定菜单
            var parentId = $.cookie(_parentCookie);
            var currentId = $.cookie(_currentCookie);
            if(parentId && currentId) {
                $('.menu-sub').eq(parentId).find('li').eq(currentId).addClass('current');
            }
			var current = $('.menu-sub .current');
            // cookie中不存在，默认展开第一个菜单项
            if(current.length <= 0) {
                current = $('.menu-sub:eq(0)').find('li:eq(0)');
                current.addClass('current');
            }
            current.parent().parent().addClass('menu-box-highlight')
            .children('.parent').children('.fa').removeClass('fa-angle-down').addClass('fa-angle-up');
			current.parent().show();
			var url = current.children('a').data('href');
            $('#iframeMain').attr('src', url);
		};
		initMenu();
    });
    </script>
</body>
</html>